
package net.lainiao;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * Created by Administrator on 2018/7/9.
 */
public class MyConst {
    public static final String QName="WORKQUEUEDEMOS";
    public static final String QName1="WORKQUEUEDEMOS1";
    public static final String QName21="SUBPUBDEMO21";
    public static final String QName22="SUBPUBDEMO22";
    public static final String EName2="SUBPUBEX2";

    public static final String QName31="SUBPUBDEMO31";
    public static final String QName32="SUBPUBDEMO32";
    public static final String EName3="SUBPUBEX3";

    public static final String QName41="SUBPUBDEMO41";
    public static final String QName42="SUBPUBDEMO42";
    public static final String EName4="SUBPUBEX4";

    public static Connection connection=null;
    public static synchronized Channel getChanel() throws IOException, TimeoutException {
        if(connection==null){
            ConnectionFactory factory=new ConnectionFactory();
            factory.setHost("localhost");
            factory.setPort(5672);
            factory.setUsername("tmcuser");
            factory.setPassword("tmcuser");
            factory.setVirtualHost("TMC");
            connection=factory.newConnection();
        }
        return connection.createChannel();
    }
}
